function [finalC, finalPayoff, finCov] = calcISG(gameModel, m)
        finCov=m;
        targets=gameModel.targets;
        Uud    =gameModel.Uud;
        Ucd    =gameModel.Ucd;
        UuaMin =gameModel.UuaMin;
        UuaMax =gameModel.UuaMax;
        UcaMin =gameModel.UcaMin;
        UcaMax =gameModel.UcaMax;
        Tsize=length(targets);
       C=zeros(Tsize,1);
       maxPayoff=0;
       minPayoff=min(Uud);
       e=0.05;
       while (maxPayoff-minPayoff)>e 
           midPoint=maxPayoff+(minPayoff-maxPayoff)/2;
           %midPoint=(maxPayoff-minPayoff)/2; 
           [ret,C, totalCov]=feasibilityCheck(midPoint,m,C);
           if strcmp(ret,'true')
                minPayoff=midPoint;
               finalPayoff=midPoint;
               finalC=C;
               finCov=totalCov;
           else
               maxPayoff=midPoint; 
           end
       end 
       
        function [ret,C, finCov]=feasibilityCheck(midPoint,m,C)
        c1=zeros(1,Tsize);
        for t=1:Tsize
          c1(t)= get_c1(t);
        end
        for t=1:Tsize
            totalCov=c1(t);
            C(t)=c1(t);
            if C(t)>1
              continue  
            end
            R=get_R(c1(t),t);
            for tj=1:Tsize
                if(t==tj)
                    continue
                end
                c2=get_c2(R,tj);
                c3=get_c3(R,tj);
                minCov=max([c3,min(c1(t),c2)]);
                if minCov<0 || minCov>1
                    break
                end
                totalCov=totalCov+minCov;
                C(tj)=minCov;
            end
            if (minCov>=0 && minCov<=1) && totalCov<=m
                ret='true';
                finCov=totalCov;
                return 
             end
        end
        finCov=m;
        ret='false';
        return 
        
        
        function c1=get_c1(t)
            %cash=1-(midPoint-Uud(t))/(Ucd(t)-Uud(t));
            cash=(midPoint-Uud(t))/(Ucd(t)-Uud(t));
            c1=max([0,cash]);        
        end
        function c2=get_c2(R,t)
            %cash=1-(R-UuaMax(t))/(UcaMax(t)-UuaMax(t));
            upBound=max(UuaMax(t),UcaMax(t));
            lowBound=min(UuaMax(t),UcaMax(t));
            if R<lowBound 
                c2=2;
                return;
            end
            
            if R>upBound 
                c2=0;
                return;
            end
            cash=(R-UuaMax(t))/(UcaMax(t)-UuaMax(t));
            c2=max([0,cash]); 
        end
        function c3=get_c3(R,t)
            %cash=1-(R-UuaMin(t))/(UcaMin(t)-UuaMin(t));
            upBound=max(UuaMin(t),UcaMin(t));
            lowBound=min(UuaMin(t),UcaMin(t));
            if R<lowBound 
                c3=2;
                return;
            end
            
            if R>upBound 
                c3=0;
                return;
            end
            cash=(R-UuaMin(t))/(UcaMin(t)-UuaMin(t));
            c3=max([0,cash]); 
        end
        function R=get_R(c1,t)
            R=(c1*UcaMin(t))+((1-c1)*UuaMin(t)-e);
        end
    end
    end